<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:80:"D:\PHPTutorial\WWW\project\public/../application/admin\view\admin\adminInfo.html";i:1541498725;s:66:"D:\PHPTutorial\WWW\project\application\admin\view\common\head.html";i:1541553784;s:68:"D:\PHPTutorial\WWW\project\application\admin\view\common\footer.html";i:1515220428;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>上海顾云数据科技中心</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/admin/layui/css/layui.css">
    <link rel="stylesheet" href="/static/admin/build/css/app.css" media="all">
</head>
<style>
    .hidden{
        display: none;
    }

</style>
<div style="overflow-x: hidden;width: 96%;margin: auto;padding-top: 1rem;">
    <div class="layui-form layui-form-pane">
        <input type="hidden" name="admin_id" value="<?php echo (isset($info['admin_id']) && ($info['admin_id'] !== '')?$info['admin_id']:''); ?>">
        <div class="layui-form-item">
            <label class="layui-form-label">选择部门</label>
            <div class="layui-input-inline">
                <select name="depart_id" lay-verify="required" lay-search lay-filter="bank_id">
                    <option value=" "></option>
                    <?php foreach($departInfo as $v): ?>
                    <option value="<?php echo $v['id']; ?>"><?php echo $v['depart_name']; ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <label class="layui-form-label">选择角色</label>
            <div class="layui-input-inline">
                <select name="role_id" lay-verify="required" lay-search>
                    <option value=" "></option>
                    <?php foreach($role as $val): ?>
                    <option value="<?php echo $val['id']; ?>"><?php echo $val['name']; ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">管理员名称</label>
            <div class="layui-input-inline">
                <input type="text" value="<?php echo (isset($info['admin_name']) && ($info['admin_name'] !== '')?$info['admin_name']:''); ?>" name="admin_name" lay-verify="required"  class="layui-input">
            </div>
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-inline">
                <input type="number" placeholder="请输入联系电话" value="<?php echo (isset($info['phone']) && ($info['phone'] !== '')?$info['phone']:''); ?>" name="phone" lay-verify="required|phone" autocomplete="No" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">

            <!--<label class="layui-form-label">职位</label>-->
            <!--<div class="layui-input-inline">-->
                <!--<input type="text" placeholder="请输入管理职位" value="<?php echo (isset($info['depart_id']) && ($info['depart_id'] !== '')?$info['depart_id']:''); ?>" name="depart_id" lay-verify="required" autocomplete="No" class="layui-input">-->
            <!--</div>-->
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登录账号</label>
            <div class="layui-input-inline">
                <input type="text"  value="<?php echo (isset($info['login_number']) && ($info['login_number'] !== '')?$info['login_number']:''); ?>" name="login_number" lay-verify="required" class="layui-input">
            </div>
            <label class="layui-form-label">登录密码</label>
            <div class="layui-input-inline">
                <input type="password" placeholder="请输入密码" value="<?php echo (isset($info['password']) && ($info['password'] !== '')?$info['password']:''); ?>" name="password" lay-verify="required" autocomplete="No" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
                <select name="status" lay-verify="required">
                    <option value="1" <?php if(isset($info)): if($info['status'] == 1): ?>selected<?php endif; endif; ?>>正常</option>
                    <option value="2" <?php if(isset($info)): if($info['status'] == 2): ?>selected<?php endif; endif; ?>>禁用</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">管理员头像</label>
            <div class="layui-upload">
                <button type="button" class="layui-btn" id="image">上传图片</button>
                <div class="layui-upload-list" style="margin-left: 7rem">
                    <img class="`" src="<?php echo (isset($info['head_img']) && ($info['head_img'] !== '')?$info['head_img']:''); ?>" style="height: 100px;" id="show_image">
                    <input type="hidden" class="value_image" value="<?php echo (isset($info['head_img']) && ($info['head_img'] !== '')?$info['head_img']:''); ?>" name="head_img">
                    <p id="demoText"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
                <!--<button type="button" class="layui-btn layui-btn-primary" id="closeIframe">关闭</button>-->
            </div>
        </div>
    </div>
</div>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/common/js/jquery.min.js"></script>
<script>
//    图片放大显示
    $('.select_img').on('click',function () {
        var img_url=$(this).data('content');
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            area: ['50%','80%'],
            skin: 'layui-layer-nobg', //没有背景色
            shadeClose: true,
            content: '<img src="'+img_url+'" />',
        });
    })
    //文件上传
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;
        //多文件列表示例
        var demoListView = $('#demoList')
            ,uploadListIns = upload.render({
            elem: '#testList'
            ,url: '<?php echo url("Upload/file_images"); ?>'
            ,accept: 'file'
            ,multiple: true
            ,auto: false
            ,bindAction: '#testListAction'
            ,choose: function(obj){
                var files = obj.pushFile(); //将每次选择的文件追加到文件队列
                //读取本地文件
                obj.preview(function(index, file, result){
                    var tr = $(['<tr id="upload-'+ index +'">'
                        ,'<td>'+ file.name +'</td>'
                        ,'<td>'+ (file.size/1014).toFixed(1) +'kb</td>'
                        ,'<td>等待上传</td>'
                        ,'<td>'
                        ,'<button class="layui-btn layui-btn-mini demo-reload layui-hide">重传</button>'
                        ,'<button class="layui-btn layui-btn-mini layui-btn-danger demo-delete">删除</button>'
                        ,'</td>'
                        ,'</tr>'].join(''));

                    //单个重传
                    tr.find('.demo-reload').on('click', function(){
                        obj.upload(index, file);
                    });

                    //删除
                    tr.find('.demo-delete').on('click', function(){
                        delete files[index]; //删除对应的文件
                        tr.remove();
                    });

                    demoListView.append(tr);
                });
            }
            ,done: function(res, index, upload){
                if(res.code == 200){ //上传成功
                    var tr = demoListView.find('tr#upload-'+ index)
                        ,tds = tr.children();
                    tds.eq(2).html('<span style="color: #5FB878;">上传成功</span><input type="hidden" name="images['+index+']" value="'+res.data.src+'">');
                    tds.eq(3).html(''); //清空操作
                    delete files[index]; //删除文件队列已经上传成功的文件
                    return;
                }
                this.error(index, upload);
            }
            ,error: function(index, upload){
                var tr = demoListView.find('tr#upload-'+ index)
                    ,tds = tr.children();
                tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
            }
        });

        //普通图片上传 单图片上传
        var uploadInst = upload.render({
            elem: '#image'
            ,url: '<?php echo url("Upload/file_images"); ?>'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#show_image').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code == 400){
                    return layer.msg('上传失败');
                }
                $('.value_image').val(res.data.src);
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
    });
</script>
<script>
    layui.use('form', function(){
        var form = layui.form;

        //获取角色
        form.on('select(bank_id)', function(data){
            var bank_id=$('select[name="bank_id"] option:checked').val();
            var html='';
            $.ajax({
                url: '<?php echo url("admin/Role/ApiGetRolePage"); ?>',
                type: 'POST',
                async:false,
                data:{bank_id:bank_id},
                dataType:'json',
                success: function (obj) {
                    var data =obj.data;
                    $.each(data,function(i,v){
                        html+='<option value="'+v.role_id+'">'+v.name+'</option>';
                    });
                    $('select[name="role_id"]').html("<option value=''>没有内容了</option>"+html);
                    form.render('select'); //这个很重要
                }
            });
        });

        //提交表单
        var url='<?php echo url("admin/Admin/ApiSaveAdminInfo"); ?>';
        form.on('submit(demo1)', function(data){
            $.post(url,data.field,function (obj) {
                if(obj.code==200){
                    parent.layer.msg(obj.msg, {icon: 6,time: 1000});
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index,data.field); //再执行关闭
                }
                if(obj.code==400){
                    parent.layer.msg(obj.msg, {icon: 5,time: 1000});
                }
            },"JSON");
        });

        $('#closeIframe').click(function(){
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });

    });
</script>

</body>
</html>